package nix.mall.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import nix.mall.common.pojo.EasyUITreeNode;
import nix.mall.common.pojo.NixMallResult;
import nix.mall.content.service.ContentCategoryService;

/**
 * 内容分类Controller
 */
@Controller
public class ContentCategoryController {

	@Autowired
	private ContentCategoryService contentCategoryService;

	@RequestMapping("/content/category/list")
	@ResponseBody
	public List<EasyUITreeNode> getContentCategoryList(@RequestParam(value = "id", defaultValue = "0") Long parentId) {
		List<EasyUITreeNode> list = contentCategoryService.getContentCategoryList(parentId);
		return list;
	}
	
	@RequestMapping("/content/category/create")
	@ResponseBody
	public NixMallResult addContentCategory(Long parentId, String name) {
		NixMallResult result = contentCategoryService.addContentCategory(parentId, name);
		return result;
	}
	
	@RequestMapping("/content/category/update")
	@ResponseBody
	public NixMallResult editContentCategory(Long id, String name) {
		NixMallResult result = contentCategoryService.editContentCategory(id, name);
		return result;
	}
	
	@RequestMapping("/content/category/delete")
	@ResponseBody
	public NixMallResult delContentCategory(Long id) {
		NixMallResult result = contentCategoryService.delContentCategory(id);
		return result;
	}
}
